import React,{Suspense} from 'react';
import { BrowserRouter,Route,Switch,Redirect } from 'react-router-dom';
import AuthRoute from './components/AuthRoute';
import { routes } from './routes';
import Loading from './pages/Loading';

const Router = ()=>{
    return (
        <BrowserRouter>
            <Suspense fallback={<Loading/>}>
                <Switch>
                    <Route exact path="/">
                            <Redirect to="/login" />
                    </Route>    
                 
                    {
                        routes.map((route,index)=>{
                            return <AuthRoute key={index} {...route} />
                        })
                    }
                    <Redirect to='/none' />
                </Switch>
            </Suspense>
        </BrowserRouter>
    )
}
export default Router;
